import Opt from '@/components/dt/info/Opt.js'
import businessCommonMgr from '@/biz/businessReport/businessCommon'
import houseOpt from '@/biz/option/house.js'
import organizationOpt from '@/biz/option/organization.js'
let companys = []
class SearchOpt extends Opt {

  constructor() {
    super()
    this.build()
  }
  getCompany() {
    let opt = {
      title: '组织筛选',
      key: 'orgIds',
      placeholder: '全部',
      tree: {
        options: companys,
        saveAll: true
      }
    }
    let params = {
      isTwoLevel: true,
    }
    businessCommonMgr
      .getOrgThreeTree(params)
      .then((res) => {
        companys = res
        opt.tree.options = companys
      })
    return opt
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    this.all = [
      this.getCompany(),
      // organizationOpt.create({
      //   key: 'orgIds',
      //   level: 3
      // }),
      // houseOpt.create({
      //   to: (info) => {
      //     return {
      //       buildingId: info.housesId
      //     }
      //   }
      // }),
      // {
      //   title: '案场名称',
      //   placeholder: '请输入案场名称',
      //   key: 'buildingName',
      //   input: {}
      // },
      {
        title: '日期',
        placeholder: '请选择日期',
        date: {
          type: 'daterange'
        },
        data: {
          to: (v) => {
            return {
              authTimeStart: v[0],
              authTimeEnd: v[1],
            }
          }
        }
      }
    ]
  }
}

export default SearchOpt